/*
 * Created by JFormDesigner on Sun Nov 28 22:17:15 CST 2021
 */

package com.xxbb.chapter_10.main_frame;

import com.xxbb.chapter_10.login_frame.LoginFrame;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author unknown
 */
public class MainFrame extends JFrame {
    public MainFrame() {
        initComponents();
    }

    private void menuItemCloseActionPerformed(ActionEvent e) {
        // TODO add your code here
        if (JOptionPane.showConfirmDialog(null, "确定要退出吗？", "退出提示", JOptionPane.OK_CANCEL_OPTION) == 0) {
            System.exit(0);
        }
    }

    private void menuItemLogoutActionPerformed(ActionEvent e) {
        // TODO add your code here
        if (JOptionPane.showConfirmDialog(null, "确定要注销吗？", "注销提示", JOptionPane.OK_CANCEL_OPTION) == 0) {
            LoginFrame loginFrame = new LoginFrame();
            loginFrame.setVisible(true);
            this.dispose();
        }
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner Evaluation license - unknown
        menuBar1 = new JMenuBar();
        menu1 = new JMenu();
        menu2 = new JMenu();
        menu3 = new JMenu();
        menu4 = new JMenu();
        menu5 = new JMenu();
        menuItemLogout = new JMenuItem();
        menuItemClose = new JMenuItem();

        //======== this ========
        setTitle("\u5b66\u751f\u7ba1\u7406\u7cfb\u7edf");
        var contentPane = getContentPane();
        contentPane.setLayout(null);

        //======== menuBar1 ========
        {

            //======== menu1 ========
            {
                menu1.setText("\u7cfb\u7edf\u8bbe\u7f6e");
            }
            menuBar1.add(menu1);

            //======== menu2 ========
            {
                menu2.setText("\u4fe1\u606f\u7ba1\u7406");
            }
            menuBar1.add(menu2);

            //======== menu3 ========
            {
                menu3.setText("\u6210\u7ee9\u7ba1\u7406");
            }
            menuBar1.add(menu3);

            //======== menu4 ========
            {
                menu4.setText("\u7528\u6237\u7ba1\u7406");
            }
            menuBar1.add(menu4);

            //======== menu5 ========
            {
                menu5.setText("\u6ce8\u9500&\u9000\u51fa");

                //---- menuItemLogout ----
                menuItemLogout.setText("\u6ce8\u9500");
                menuItemLogout.addActionListener(e -> menuItemLogoutActionPerformed(e));
                menu5.add(menuItemLogout);

                //---- menuItemClose ----
                menuItemClose.setText("\u9000\u51fa");
                menuItemClose.addActionListener(e -> menuItemCloseActionPerformed(e));
                menu5.add(menuItemClose);
            }
            menuBar1.add(menu5);
        }
        setJMenuBar(menuBar1);

        {
            // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < contentPane.getComponentCount(); i++) {
                Rectangle bounds = contentPane.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = contentPane.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            contentPane.setMinimumSize(preferredSize);
            contentPane.setPreferredSize(preferredSize);
        }
        setSize(685, 405);
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner Evaluation license - unknown
    private JMenuBar menuBar1;
    private JMenu menu1;
    private JMenu menu2;
    private JMenu menu3;
    private JMenu menu4;
    private JMenu menu5;
    private JMenuItem menuItemLogout;
    private JMenuItem menuItemClose;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
